<?php

namespace app\admin\controller;

use app\common\middleware\Auth;
use think\facade\Request;

class Info
{
    protected $middleware = [Auth::class => []];

    public function Index()
    {
        return ViewTpl('/admin/info');
    }

    public function Log()
    {
        if (Request::isAjax() || Request::isPost()) {
            $Lists = new \app\admin\service\oldlog\Lists();
            $data['rows'] = $Lists->Lists(input());//列表数据
            $data['total'] = $Lists->Total(input());//总数据
            return BackCode($data);
        }
    }

    /*Tab及统计*/
    public function Tabsum()
    {
        if (Request::isAjax() || Request::isPost()) {
            $Lists = new \app\admin\service\oldlog\Lists();
            $data['tab'] = $Lists->Tab(input());//Tab统计
            $data['sum'] = $Lists->Sum(input());//Sum统计
            return BackCode($data);
        }
    }

    public function Edit()
    {
        if (Request::isAjax() || Request::isPost()) {
            $Logic = new \app\admin\service\user\Logic();

            $params = input();
            $params['id'] = GetToken("id");
            $params['user'] = GetToken("user");
            $params['role_ids'] = GetToken("role_ids");
            $params['department_ids'] = GetToken("department_ids");
            $data = $Logic->Edit($params);
            return BackCode($data['data'], $data['code'], $data['msg']);
        }
    }

    public function Detail()
    {
        if (Request::isAjax() || Request::isPost()) {
            $Logic = new \app\admin\service\user\Logic();
            $params = input();
            $params['id'] = GetToken("id");
            $data = $Logic->Detail($params);
            return BackCode($data['data'], $data['code'], $data['msg']);
        }
    }

}